package com.lzx.adx.report.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lzs.adx.commmon.service.impl.CrudServiceImpl;

import com.lzx.adx.report.dao.MonitorTemplateDao;
import com.lzx.adx.report.dto.MonitorTemplateDTO;
import com.lzx.adx.report.entity.MonitorTemplateEntity;
import com.lzx.adx.report.service.MonitorTemplateService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Map;

/**
 * 监测地址模板
 *
 * @author wangzhijun 825400558@qq.com
 * @since 1.0.0 2023-11-29
 */
@Service
public class MonitorTemplateServiceImpl extends CrudServiceImpl<MonitorTemplateDao, MonitorTemplateEntity, MonitorTemplateDTO> implements MonitorTemplateService {

    @Override
    public QueryWrapper<MonitorTemplateEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<MonitorTemplateEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public MonitorTemplateDTO getDetail(Serializable id) {
        MonitorTemplateEntity monitorTemplateEntity = this.baseDao.selectById(id);
        MonitorTemplateDTO monitorTemplateDTO=new MonitorTemplateDTO();
        BeanUtils.copyProperties(monitorTemplateEntity,monitorTemplateDTO);
        return monitorTemplateDTO;
    }

    @Override
    public void delete(Serializable[] ids) {
        for (Serializable id : ids) {
            this.baseDao.deleteById(ids);
        }

    }
}